<?php
// AUTHORIZATION
if(!empty($_POST['login']) && !empty($_POST['pwd']))
{
   $remember = isset($_POST['remember']) && config::read('autologin_timeout') ? TRUE : FALSE;
   session::authorize($_POST['login'], $_POST['pwd'], $remember);
}
// LOGOUT
if(isset($_REQUEST['logout']))
{
   session::logout();
   header('location: /admin/index.php');
}

if(session::user() && session::user()->hasRole('ADMIN_ACCESS'))
{
   // PROCEED IF LOGED IN
   $layout = 'framer.html';
} else
{
   // LOGIN FORM
   $layout = 'login.html';
}